<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{Title} (Add)</title>
<link rel="stylesheet" href="../../css/mem_main.css?t={ctime}" type="text/css">
<script Language="JavaScript1.2" type="text/javascript" src="../../inc/layshow.js?t={ctime}"></script>
<script Language="JavaScript1.2" type="text/javascript" src="../../inc/checkdata_{intLang}.js?t={ctime}"></script>
<script Language="JavaScript">
<!--
function finalcheck(){
	with(document.beMemberFrm){
		if(Check(document.beMemberFrm)){
			if(!isCorrectAccount(document.beMemberFrm["data[Account_x]"].value))return false;

			if(document.beMemberFrm["data[Password_x]"].value != document.beMemberFrm["Password_c"].value){
				alert("{Add_alert1}");  //"代理商密碼 和 代理商密碼確認 不一樣！(確認大小是否相同)"
				document.beMemberFrm["data[Password_x]"].focus();
			}else{
				var i = 0, c1 = 0, c2 = 0, intMinScale, S1 = 0, S2 = 0;
				intMinScale = parseInt(document.getElementById("ChildMinScale").innerHTML);	//已使用
				S1 = parseInt(document.beMemberFrm["data[Scale_n]"].value);
				S2 = parseInt(document.beMemberFrm["data[MainScale_n]"].value);
				c1 = parseInt(document.beMemberFrm.ResidualCredit.value);   //剩餘
				c2 = parseInt(document.beMemberFrm["data[CreditLine_n]"].value);
				if(c1 < c2){
					alert("{Add_alert3}"+c1);
					document.beMemberFrm["data[CreditLine_n]"].focus();
					return;
				}else if(intMinScale > (S1+S2)){
					alert("{ChildScale} : "+intMinScale+" %");
					document.beMemberFrm["data[Scale_n]"].focus();
					return;
				}
				submit();
			}
		}
	}
}

function CompareScale(select1, select2, MaxScale, MinScale){
	var S1 = 0, S2 = 0, i = 0, Gap1 = 0, Gap2 = 0;
	S1 = parseInt(document.beMemberFrm[select1].value);
	S2 = parseInt(document.beMemberFrm[select2].value);
	Gap1 = MaxScale - S1;
	Gap2 = MinScale - S1;
	if(Gap1 < S2)S2 = Gap1;
	if(Gap2 > S2)S2 = Gap2;
	for(i = 0; i < document.beMemberFrm[select2].options.length; i ++){
		if(parseInt(document.beMemberFrm[select2].options[i].value) == S2){
			document.beMemberFrm[select2].selectedIndex = i;
		}
	}
}

function SearchAccount(){
	document.SearchForm.Account.value = document.beMemberFrm["data[Account_x]"].value;
	document.SearchForm.submit();
}

function BalanceCredit(){
	var intResidualCredit = eval(document.beMemberFrm.ResidualCredit.value);
	var intCreditLine = eval(document.beMemberFrm["data[CreditLine_n]"].value);
	if(isNaN(intResidualCredit))intResidualCredit = 0;
	if(isNaN(intCreditLine))intCreditLine = 0;
	if(intCreditLine > intResidualCredit){
		intCreditLine = intResidualCredit;
		document.beMemberFrm["data[CreditLine_n]"].value = intCreditLine;
	}
	document.getElementById("UUCredit").innerHTML = intResidualCredit - intCreditLine;
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<!-- 檢驗資料用 //-->
<form name="CheckDataForm">
	<input type="hidden" name="required" value="text;data[ParentID_n];{ParentID}">
	<input type="hidden" name="required" value="text;data[Account_x];{MemAccount}">
	<input type="hidden" name="required" value="text;data[Password_x];{MemPassword}">
	<input type="hidden" name="required" value="text;Password_c;{MemPassword_c}">
	<input type="hidden" name="required" value="text;data[Name_x];{MemName}">
	<input type="hidden" name="required" value="int;data[Scale_n];{Scale}">
	<input type="hidden" name="required" value="int;data[CreditLine_n];{CreditLine}">
</form>
<!-- End //-->

<form name="beMemberFrm" method="GET" action="index.php">
<input type="hidden" name="op" value="Insert">
<table width="770" border="0" cellspacing="0" cellpadding="0" class="cmti">
  <tr> 
    <td>{Title}: {Add}-- 
      <input type="button" value="{Add}" class="zabutton" onClick="location.href='index.php?op=Add'">
      <input type="button" value="{List}" class="zabutton" onClick="location.href='index.php?op=Lists'">
      <input type="button" value="{Search}" class="zabutton" onClick="location.href='index.php?op=Search'">
    </td>
  </tr>
</table>

<div class="ctabdv"> 
<table width="500" border="0" cellspacing="1" cellpadding="0" class="ctab">
  <tr> 
    <td colspan="2" class="cedti">{BaseData}</td>
  </tr>
  <tr class="clef"> 
    <td width="120" class="ctigaed">{ParentID}</td>
    <td>{ParentSelectTag}</td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{MemAccount}</td>
    <td> 
      <input type="text" name="data[Account_x]" size="10" class="zatexted">
      <input type="button" value="{SeachAccount}" class="zabutton" onclick="SearchAccount()">
    </td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{MemName}</td>
    <td><input type="text" name="data[Name_x]" size="10" class="zatexted"></td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{MemPassword}</td>
    <td><input type="password" name="data[Password_x]" size="10" class="zatexted"></td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{MemPassword_c}</td>
    <td><input type="password" name="Password_c" size="10" class="zatexted"></td>
  </tr>
  <tr class="clef"><td colspan="2" class="cedti">{WagerData}</td></tr>
  <tr class="clef"> 
    <td class="ctigaed">{isLock}</td>
    <td>
      <input type="radio" name="data[isLock_x]" value="0" class="zadot" checked>{UnLocked}&nbsp;
      <input type="radio" name="data[isLock_x]" value="1" class="zadot">{Locked}&nbsp;
      <input type="radio" name="data[isLock_x]" value="2" class="zadot">{StopWager}</td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{isBetList}</td>
    <td> 
      <input type="radio" name="data[isBetList_x]" value="1" class="zadot" checked>{UnLocked}&nbsp; 
      <input type="radio" name="data[isBetList_x]" value="0" class="zadot">{Locked}</td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{CreditLine}</td>
    <td><input type="text" name="data[CreditLine_n]" size="10" class="zatexted" onkeyup="BalanceCredit()">
		<font color="#0000FF">({ResidualCredit} : <a id="UUCredit" style="font-weight: 700">{ShowResidualCredit}</a>)</font>
		<input type="hidden" name="ResidualCredit" value="{ShowResidualCredit}">
	</td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{Agency}{Scale}</td>
    <td>{ScaleSelectTag}</td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{ParentID}{Scale}</td>
    <td> 
      {MainScaleSelectTag}
      <font color="#0000FF">( {ChildScale} : <a id="ChildMinScale">{ShowResidualScale}</a>%) </font></td>
  </tr>
  <tr class="clef"> 
    <td class="ctigaed">{isSupple}</td>
    <td>
      <input type="radio" name="data[isSupple_x]" value="1" class="zadot">{UnLocked}&nbsp;
      <input type="radio" name="data[isSupple_x]" value="0" class="zadot" checked>{Locked}</td>
  </tr>
  <tr class="clef"> 
    <td colspan="2" class="cedfoot"> 
      <input type="button" value="{Add}" class="zabutton" onclick="finalcheck()">&nbsp;&nbsp;&nbsp; 
      <input type="Reset" value="{Reset}" class="zabutton">
    </td>
  </tr>
</table>
</div>
</form>
<iframe name="SearchIF" src="" width="0" height="0"></iframe>
<form name="SearchForm" action="/k_admin/SearchAccount.php" target="SearchIF"><input type="hidden" name="Account" value=""></form>
</body>
</html>
